//
//  YCAllTeachVideoCell.m
//  YCSchool
//
//  Created by Kylin on 16/5/7.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//

#import "YCAllTeachVideoCell.h"

@interface YCAllTeachVideoCell()
/**imageView*/
@property(nonatomic,weak)UIImageView *showImageView;
@end

@implementation YCAllTeachVideoCell

+(CGFloat)getCellHeight{
    return 219;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupChildViews];
    }
    
    return self;
}

// 初始化自定义所有的子控件
- (void)setupChildViews{
    
    [self setupShowImageViewChildViews];
    
    [self setupTarBarViewChildViews];
    
}

// 设置播放视图的模块
- (void)setupShowImageViewChildViews{
    UIImageView *showImageView = [[UIImageView alloc]init];
    showImageView.contentMode = UIViewContentModeScaleAspectFill;
    showImageView.clipsToBounds = YES;
    _showImageView = showImageView;
    [self.contentView addSubview:showImageView];
    showImageView.image = [UIImage imageNamed:@"beauty.jpg"];
    
    UIButton *playBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [playBtn setImage:[UIImage imageNamed:@"大播放"] forState:UIControlStateNormal];
    [showImageView addSubview:playBtn];
    
    UILabel *ycLabel = [[UILabel alloc]init];
    ycLabel.font = [UIFont boldSystemFontOfSize:16];
    ycLabel.textColor = [UIColor whiteColor];
    ycLabel.text = @"一乘教学视频";
    [showImageView addSubview:ycLabel];
    
    UILabel *subTitle = [[UILabel alloc]init];
    subTitle.font = [UIFont boldSystemFontOfSize:16];
    subTitle.textColor = [UIColor whiteColor];
    subTitle.text = @"上车准备与夜间模式";
    [showImageView addSubview:subTitle];
    // 添加约束
    [showImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.contentView);

    }];
    
    [playBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(showImageView);
        make.width.height.equalTo(@42);
        make.bottom.equalTo(showImageView).offset(-59);
    }];
    
    [ycLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(showImageView).offset(18);
        
    }];
    
    [subTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(ycLabel);
        make.height.equalTo(@32);
        make.top.equalTo(ycLabel.mas_bottom).offset(7);
    }];

}

// 设置底部控件的子控件
- (void)setupTarBarViewChildViews{
    
    // 图片下面的父控件
    UIView *tabBarView = [[UIView alloc]init];
    [self.contentView addSubview:tabBarView];
    
    // 播放模块
    UIView *playView = [[UIView alloc]init];
    [tabBarView addSubview:playView];
    
    // 评论模块
    UIView *commentView = [[UIView alloc]init];
    [tabBarView addSubview:commentView];
    
    
    [tabBarView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.contentView);
        make.top.equalTo(self.showImageView.mas_bottom);
        make.height.equalTo(@40);

    }];
    
    [commentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(tabBarView);
        make.height.equalTo(@22);
        make.right.equalTo(tabBarView).offset(-17);
        make.width.equalTo(@55);
    }];

    [playView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(tabBarView);
        make.right.equalTo(commentView.mas_left).offset(-45);
        make.height.equalTo(@22);
        make.width.equalTo(@55);
    }];
    
    // 调用方法添加控件的子模块
    [self setupPlayContentView:playView];
    [self setupCommentContentView:commentView];

}


// 播放次数的模块
- (void)setupPlayContentView:(UIView *)playView{
    UILabel *countLabel = [[UILabel alloc]init];
    countLabel.font = [UIFont systemFontOfSize:11];
    countLabel.textColor = YCcommonLabelColor
    countLabel.text = @"3333";
    UILabel *playLabel = [[UILabel alloc]init];
    playLabel.font = [UIFont systemFontOfSize:11];
    playLabel.textColor =YCcommonLabelColor
    playLabel.text = @"播放";
    
    [playView addSubview:countLabel];
    [playView addSubview:playLabel];
    
    [playLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.equalTo(playView);
        make.right.equalTo(countLabel).offset(-5);
    }];
    
    [countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.bottom.equalTo(playView);
    }];
    

}

// 评论次数的模块
- (void)setupCommentContentView:(UIView *)commentView{
    UILabel *commentLabel = [[UILabel alloc]init];
    commentLabel.font = [UIFont systemFontOfSize:11];
    commentLabel.textColor = YCcommonLabelColor
    commentLabel.text = @"评论";
    UILabel *countLabel = [[UILabel alloc]init];
    countLabel.font = [UIFont systemFontOfSize:11];
    countLabel.textColor = YCcommonLabelColor
    countLabel.text = @"2222";
    
    
    [commentView addSubview:commentLabel];
    [commentView addSubview:countLabel];
    
    [commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.equalTo(commentView);
        make.right.equalTo(countLabel).offset(-5);
    }];
    
    [countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.bottom.equalTo(commentView);
    }];

}
@end






